<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>embedme: libemb/inc/PacketPort.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.8 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>文件成员</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_574d9269cd334a9d02d8928365303d98.html">libemb</a></li><li class="navelem"><a class="el" href="dir_207aad82934689048a9003fb51f06f7f.html">inc</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">PacketPort.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_packet_port_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef __PACKET_PORT_H__</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define __PACKET_PORT_H__</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_base_type_8h.html">BaseType.h</a>&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_com_port_8h.html">ComPort.h</a>&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_thread_8h.html">Thread.h</a>&quot;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_ring_buffer_8h.html">RingBuffer.h</a>&quot;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_mutex_8h.html">Mutex.h</a>&quot;</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#define PORT_BUFF_SIZE      64      </span><span class="comment">/* 端口读缓存大小 */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#define PACK_SIZE_MAX       128     </span><span class="comment">/* 最大包长度 */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno"><a class="line" href="class_c_packet.html">   19</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_c_packet.html">CPacket</a>{</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    uint32 m_size;</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="keywordtype">char</span>   m_data[PACK_SIZE_MAX];</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;};</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="class_packet_port.html">   31</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_packet_port.html">PacketPort</a>:<span class="keyword">public</span> <a class="code" href="class_runnable_protocol.html">RunnableProtocol</a>{</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    <a class="code" href="class_packet_port.html">PacketPort</a>();</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    <span class="keyword">virtual</span> ~<a class="code" href="class_packet_port.html">PacketPort</a>();</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <a class="code" href="class_i_o_device.html">IODevice</a>* getPort(){<span class="keywordflow">return</span> m_device;}</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    sint32 <a class="code" href="class_packet_port.html#ac90634a0db6968cc849d59aeb66a1dca">bind</a>(<a class="code" href="class_i_o_device.html">IODevice</a>* device);</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    sint32 <a class="code" href="class_packet_port.html#a407a6dfb2ba8f76a9ed76a5ee7f705ce">unbind</a>();</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    sint32 <a class="code" href="class_packet_port.html#a18c0ea87a53f7c2eeb60393153b7b9cf">sendPacket</a>(<span class="keyword">const</span> <a class="code" href="class_c_packet.html">CPacket</a>&amp; packet);</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">void</span> recvPacket(<span class="keyword">const</span> <span class="keywordtype">char</span>* buf, sint32 len)=0;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <span class="keywordtype">void</span> run();</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <span class="keywordtype">void</span> recvTask(<span class="keywordtype">void</span>* arg);</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <a class="code" href="class_i_o_device.html">IODevice</a>* m_device;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <a class="code" href="class_thread.html">Thread</a> m_mainThread;</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <a class="code" href="class_ring_buffer.html">RingBuffer</a>* m_recvBuffer;</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    sint32 m_recvTaskStatus;</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;};</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="class_packet_port_html_ac90634a0db6968cc849d59aeb66a1dca"><div class="ttname"><a href="class_packet_port.html#ac90634a0db6968cc849d59aeb66a1dca">PacketPort::bind</a></div><div class="ttdeci">sint32 bind(IODevice *device)</div><div class="ttdoc">绑定端口设备 </div><div class="ttdef"><b>Definition:</b> PacketPort.cpp:31</div></div>
<div class="ttc" id="class_i_o_device_html"><div class="ttname"><a href="class_i_o_device.html">IODevice</a></div><div class="ttdoc">IO设备抽象类 </div><div class="ttdef"><b>Definition:</b> IODevice.h:49</div></div>
<div class="ttc" id="class_thread_html"><div class="ttname"><a href="class_thread.html">Thread</a></div><div class="ttdoc">线程类 </div><div class="ttdef"><b>Definition:</b> Thread.h:64</div></div>
<div class="ttc" id="class_c_packet_html"><div class="ttname"><a href="class_c_packet.html">CPacket</a></div><div class="ttdoc">协议包类. </div><div class="ttdef"><b>Definition:</b> PacketPort.h:19</div></div>
<div class="ttc" id="class_packet_port_html_a407a6dfb2ba8f76a9ed76a5ee7f705ce"><div class="ttname"><a href="class_packet_port.html#a407a6dfb2ba8f76a9ed76a5ee7f705ce">PacketPort::unbind</a></div><div class="ttdeci">sint32 unbind()</div><div class="ttdoc">解绑端口设备 </div><div class="ttdef"><b>Definition:</b> PacketPort.cpp:58</div></div>
<div class="ttc" id="_ring_buffer_8h_html"><div class="ttname"><a href="_ring_buffer_8h.html">RingBuffer.h</a></div></div>
<div class="ttc" id="_thread_8h_html"><div class="ttname"><a href="_thread_8h.html">Thread.h</a></div></div>
<div class="ttc" id="_com_port_8h_html"><div class="ttname"><a href="_com_port_8h.html">ComPort.h</a></div></div>
<div class="ttc" id="_mutex_8h_html"><div class="ttname"><a href="_mutex_8h.html">Mutex.h</a></div></div>
<div class="ttc" id="class_runnable_protocol_html"><div class="ttname"><a href="class_runnable_protocol.html">RunnableProtocol</a></div><div class="ttdoc">线程接口 </div><div class="ttdef"><b>Definition:</b> Thread.h:36</div></div>
<div class="ttc" id="class_ring_buffer_html"><div class="ttname"><a href="class_ring_buffer.html">RingBuffer</a></div><div class="ttdoc">循环缓冲类 </div><div class="ttdef"><b>Definition:</b> RingBuffer.h:36</div></div>
<div class="ttc" id="class_packet_port_html_a18c0ea87a53f7c2eeb60393153b7b9cf"><div class="ttname"><a href="class_packet_port.html#a18c0ea87a53f7c2eeb60393153b7b9cf">PacketPort::sendPacket</a></div><div class="ttdeci">sint32 sendPacket(const CPacket &amp;packet)</div><div class="ttdoc">发送数据包 </div><div class="ttdef"><b>Definition:</b> PacketPort.cpp:88</div></div>
<div class="ttc" id="class_packet_port_html"><div class="ttname"><a href="class_packet_port.html">PacketPort</a></div><div class="ttdoc">协议包端口类 </div><div class="ttdef"><b>Definition:</b> PacketPort.h:31</div></div>
<div class="ttc" id="_base_type_8h_html"><div class="ttname"><a href="_base_type_8h.html">BaseType.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2016年 一月 12日 星期二 15:48:37 , 为 embedme使用  &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.8
</small></address>
</body>
</html>
